<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo C('site_name');?></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">

<script type="text/javascript" src="<?php echo STATICS;?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo STATICS;?>/js/jquery.form.min.js"></script>
<script type="text/javascript" src="<?php echo STATICS;?>/layui/lay/dest/layui.all.js"></script>
<script type="text/javascript" src="<?php echo STATICS;?>/js/regExp.js"></script>
<script type="text/javascript" src="<?php echo RES;?>/js/common.js"></script>

<link rel="stylesheet" href="<?php echo STATICS;?>/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="<?php echo STATICS;?>/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo RES;?>/css/global.css" media="all">
<script>
$(function(){
	//ajaxform
	var options = { 
		dataType:'json',
		beforeSubmit:showRequest,//表单验证方式
        success:showResponse  // post-submit callback 
    }; 

    $('#iframForm').ajaxForm(options); 

    function showResponse(responseText, statusText)  {
    	$('#iframForm button').removeAttr('disabled');
    	$('#iframForm input').removeAttr('disabled');
		if (statusText == 'success') {
			parent.layer.close(load);
			if (responseText.status==1) {
				parent.layer.open({
					type:0, 
					icon:1,
					content:responseText.info,
					time:3000,
					end: function(){ 
						var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
						parent.layer.close(index);
						parent.location.reload();
					} 
				});
			}else{
				parent.layer.open({
					type:0, 
					icon:2,
					content:responseText.info
				});
			}
		}else{
			parent.layer.msg('服务器错误');
		}
	} 

	function showRequest(){
		$('#iframForm button').attr("disabled","disabled");
		$('#iframForm input').attr("disabled","disabled");
		load = parent.layer.load(0,{shade: [0.7, '#000000']});
	}
})
</script>

</head>
<body>
<div class="iframeBox">
	<form id="iframForm" class="layui-form" method="post" action="<?php echo U('Chexing/add');?>">
		<div class="layui-form-item">
			<label class="layui-form-label">车型名称</label>
			<div class="layui-input-block">
				<input type="text" name="carName" lay-verify="required" class="layui-input" >
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">品牌</label>
			<div class="layui-input-inline">
				<select name="brandID" id="brandID" lay-verify="required" lay-filter="brandID">
		    	<option value="">==请选择==</option>
					<?php if(is_array($c_data["brand"])): $i = 0; $__LIST__ = $c_data["brand"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo['id']); ?>"><?php echo ($vo['name']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
		        </select>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">年款</label>
			<div class="layui-input-inline">
				<input type="text" name="year" lay-verify="required" value="" class="layui-input" />
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
			</div>
		</div>
		<input type="hidden" name="brandName" id="brandName" />
	</form>
</div>

<script>
$(function(){		
	var form = layui.form();
	form.on('select(brandID)', function(data){	
		name = data.elem[data.elem.selectedIndex].text;
		$("#brandName").val(name);
	}); 

})
</script>
</body>
</html>